import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home/index.vue'
import PageTransition from './views/PageTransition.vue'
Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'PageTransition',
      component: PageTransition,
      children:[
       {
        path:'',
         name: 'Home',
        component: Home,
        meta: {
          TabbarShow: true, // 需要显示 底部导航
          title:'首页' , //标题
          arrow:false, //返回上页箭头
          icon:true, //右侧图标
        }
      },
        {
          path: '/About',
          name: 'About',
          component: () => import('./views/About/index.vue'),
          meta: {
            TabbarShow: true, // 需要显示 底部导航
            title:'推荐' , //标题
            arrow:false, //返回上页箭头
            icon:true, //右侧图标
            requireAuth:true//true为这个页面需要登录权限
          }
        },
        {
          path: '/mine',
          name: 'mine',
          component: () => import('./views/Mine/index.vue'),
          meta: {
            TabbarShow: true, // 需要显示 底部导航
            title:'我的' , //标题
            arrow:false, //返回上页箭头
            icon:true, //右侧图标
          }
        },
        {
          path: '/cart',
          name: 'cart',
          component: () => import('./views/Cart/index.vue'),
          meta: {
            TabbarShow: true, // 需要显示 底部导航
            title:'购物车' , //标题
            arrow:false, //返回上页箭头
            icon:true, //右侧图标
          }
        },
        {
          path: '/detail',
          name: 'detail',
          component: () => import('./views/Detail/index.vue'),
          meta: {
            TabbarShow: false, // 需要显示 底部导航
            title:'子页面' , //标题
            arrow:true, //返回上页箭头
            icon:false, //右侧图标
            keepAlive:true,
          },


          //路由独享钩子 判断进入某个页面判断有没有这个标识 没有则返回登录
          // beforeEnter: (to, from, next) => {
          //   if(!localStorage.getItem('loginTime')){
          //     next('/About')
          //   }
          //   next()
          // }
        },
        {
          path: '/detailto',
          name: 'detailto',
          component: () => import('./views/DetailTo/index.vue'),
          meta: {
            TabbarShow: false, // 需要显示 底部导航
            title:'子页面' , //标题
            arrow:true, //返回上页箭头
            icon:false, //右侧图标
          },

          //路由独享钩子 判断进入某个页面判断有没有这个标识 没有则返回登录
          // beforeEnter: (to, from, next) => {
          //   if(!localStorage.getItem('loginTime')){
          //     next('/About')
          //   }
          //   next()
          // }
        },
        {
          path: "/404",
          name: "not-found",
          component: ()=>import('./views/NotFound/index'),
          meta: {
            TabbarShow: false, // 需要显示 底部导航
            title:'页面未找到' , //标题
            arrow:true, //返回上页箭头
            icon:false, //右侧图标
          },
        },
        {
          path: "*",
          redirect: "/404"
        }
      ],

    },




  ]
})
